package com.ts.main.admin.controller;

import com.ts.main.admin.dto.ProductVariantDto;
import com.ts.main.admin.dto.ProductVariantSearchPageDto;
import com.ts.main.admin.exception.R;
import com.ts.main.admin.exception.RPage;
import com.ts.main.admin.service.ProductVariantServiceImpl;
import com.ts.main.admin.vo.ProductPartVo;
import com.ts.main.admin.vo.ProductVariantVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:lk
 * @Date: 2025/6/11  04:37
 */
@AllArgsConstructor
@RestController
@RequestMapping("/productVariant")
@Tag(name = "商品管理-商品组合（SKU）管理")
public class ProductVariantController {

    private final ProductVariantServiceImpl productVariantService;

    @PostMapping("/getProductVariantPage")
    @Operation(summary = "查询商品组合列表（分页）")
    public RPage<List<ProductVariantVo>> getProductVariantPage(@RequestBody ProductVariantSearchPageDto dto) {
        return productVariantService.getProductVariantPage(dto);
    }

    @GetMapping("/getProductVariantDetails")
    @Operation(summary = "查询商品组合详情")
    public R<ProductVariantVo> getProductVariantDetails(@Schema(description = "商品组合ID")
                                                        @RequestParam("variantId") Integer variantId) {
        return R.ok(productVariantService.getProductVariantDetails(variantId));
    }

    @GetMapping("/getProductPartList")
    @Operation(summary = "查询商品列表（筛选项）")
    public R<List<ProductPartVo>> getProductPartList() {
        return R.ok(productVariantService.getProductPartList());
    }

//    @PostMapping("/saveProductVariant")
//    @Operation(summary = "添加商品组合",hidden = true)
//    public R<Boolean> saveProductVariant(@RequestBody ProductVariantDto dto) {
//        return R.ok(productVariantService.saveProductVariant(dto));
//    }
//
//    @PutMapping("/updateProductVariant")
//    @Operation(summary = "修改商品组合",hidden = true)
//    public R<Boolean> updateProductVariant(@RequestBody ProductVariantDto dto) {
//        return R.ok(productVariantService.updateProductVariant(dto));
//    }
//
//    @DeleteMapping("/deleteProductVariant")
//    @Operation(summary = "删除商品组合",hidden = true)
//    public R<Boolean> deleteProductVariant(@Schema(description = "商品组合ID")
//                                          @RequestParam("variantId") Integer variantId) {
//        return R.ok(productVariantService.deleteProductVariant(variantId));
//    }

    /**
     * 一键生成商品SKU
     */
    @GetMapping("/initProductSku")
    @Operation(summary = "一键生成商品SKU")
    public R<Boolean> initProductSku(@Schema(description = "商品ID") @RequestParam Integer productId) {
        return R.ok(productVariantService.initProductSku(productId));
    }

}